import java.util.Arrays;
public class SZJOchange {
    //调整数组顺序使得奇数位于偶数之前。
    public static void main(String[] args) {
        int  len = 0;//arr2可能的长度
        int[] arr1 = {1,2,3,4,5,6,7};
       if(arr1.length % 2 != 0) {
         len = (arr1.length/2) + 1;
       }else {
           len =arr1.length/2;
       }
        int[] arr2 = new int[len];
        int[] arr3 = new int[arr1.length/2];
        int a = 0;
        int b = 0;
        int c = 0;
        for (int i = 0; i < arr1.length ; i++) {
                    if (i % 2 == 0) {
                       arr2[a] =arr1[i];
                        a++;
                    }else {
                        arr3[b] = arr1[i];
                        b++;
                }
            }
        for (int i = 0; i < arr1.length/2; i++) {
            arr1[c] = arr2[i];
            c++;
        }
        if(arr1.length % 2 != 0) {
            arr1[arr1.length/2] =arr2[len-1];
        }

        for (int i = 0; i < arr1.length/2; i++) {
            if(arr1.length%2!=0) {
                arr1[c+1] =arr3[i];
                c++;
            }else {
                arr1[c] =arr3[i];
                c++;
            }

        }
        System.out.println(Arrays.toString(arr1));
        }
    }

